import 'package:flutter/material.dart';
import 'package:todo_app/layout/Gaps.dart';

const UserNameAvatarColors = <Color>[
  Color(0xFF2db7f5),
  Color(0xFF87d068),
  Color(0xFF108ee9),
  Color(0xFF19be6b),
  Color(0xFF06605d),
  Color(0xFF4daf86),
  Color(0xFFff5500)
];

class UserNameAvatar extends StatelessWidget {
  const UserNameAvatar({super.key, required this.username, required this.size, this.fontSize});
  final String username;
  final double size;
  final double? fontSize;

  @override
  Widget build(BuildContext context) {
    var index = username.codeUnitAt(0) % UserNameAvatarColors.length;
    return Container(
      width: size,
      height: size,
      alignment: Alignment.center,
      decoration: BoxDecoration(
        color: UserNameAvatarColors[index],
        borderRadius: BorderRadius.circular(size / 2)
      ),
      child: Text(username[0], style: TextStyle(color: Colors.white, fontSize: fontSize ?? 20.dp),),
    );
  }
}